// menu独立的模块 模块拆分
import {menuList} from '../../../request/api'
// state
const state= {
    menulist:[]
}

const getters = {
    getMenu(state){
        return state.menulist
    }
}

const mutations={
    REQ_MENULIST(state,payload){
        state.menulist=payload
    }
}

const actions={
    // 封装一个获取列表的行动
    getMenuListAciton({commit}){
        // 调用接口
        menuList({
            istree:1
        })
        .then(res=>{
            // console.log(res)
            if(res.code==200){
                commit('REQ_MENULIST',res.list)
            }
        })
    }
}

export default {
    state,
    getters,
    mutations,
    actions,
    // 开启命名空间
    namespaced:true
}